<?php
  define('ACC', true); 
  require('./include/init.php'); 
  //$mysql = mysql::getIns();
  $user = new usermodel();
  $userinfo = $_POST;
  //$userinfo = array('user_id'=>5, 'user_name'=>'wanxi', 'user_pwd'=>'111111', 'class_id'=>'1', 'user_phone'=>'18611796983', 'user_email'=>'wanxi_pku1@yahoo.com','user_last'=>'hishew'); 
  $userinfo = $user ->_facade($userinfo);
  $userinfo = $user ->autoFill($userinfo);  
  //print_r ($userinfo);
  
  
  if($user->checkUser($userinfo['user_name'])) {
    $msg = 'User exists';
    include(ROOT . 'view/msg.html');
    exit;
}
  
  
  if ($user -> reg($userinfo)){
      //$msg = 'Success';
      $u = $userinfo['user_name'];
      $p = $userinfo['user_pwd'];
      $row = $user->checkUser($userinfo['user_name'], $userinfo['user_pwd']);
      session_start();
      $_SESSION = $row; 
      include(ROOT . 'view/register_success.html'); 
      
      }else{
      $msg = 'Fail';
      include(ROOT . 'view/msg.html');  
  } 

          
          
      
  //print_r( $user ->select()); 
  ?>
